package com.kornero.common.util;

import org.apache.commons.lang3.StringUtils;

public class ActivityUtil {

    private static final String DOT = ".";
    private static final String PREFERENCES_SUFFIX = "Preferences";

    public static String getTag(final Class<?> aClass) {
        return toLowerDotedFromCamelCase(aClass.getSimpleName());
    }

    public static String getPreferencesName(final Class<?> aClass) {
        return toLowerDotedFromCamelCase(aClass.getSimpleName() + PREFERENCES_SUFFIX);
    }

    public static String toLowerDotedFromCamelCase(final String s) {
        final String[] parts = StringUtils.splitByCharacterTypeCamelCase(s);
        final StringBuilder result = new StringBuilder();
        for (final String part : parts) {
            result.append(part).append(DOT);
        }
        return result.substring(0, result.length() - 1).toLowerCase();
    }
}